<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<button>获取users</button>

<script src="/public/kxios/kxios.js"></script>

<script>
    let btns = document.querySelectorAll('button');

    btns[0].onclick = function() {
        // kxios({
        //     method: 'get',
        //     url: '/users'
        // }).then(data => {
        //     console.log(data)
        // })

        // let kxios = new Kxios({
        //     baseURL: '/api',
        // });

        // kxios.request({
        //     url: '/users'
        // }).then(data => {
        //     console.log(data);
        // });

        // kxios.defaults.baseURL = '/api';

        // let token = localStorage.getItem('token');
        // kxios.defaults.headers.authorization = token;

        console.dir(kxios);

        kxios.interceptors.request.use( function(config) {
            console.log('request - 1', config);
            return config;
        }, function() {

        } );
        kxios.interceptors.request.use( function(config) {
            console.log('request - 2', config);
            return config;
        }, function() {

        } );


        kxios.interceptors.response.use( function(data) {
            console.log('response - 1', data);
            return data;
        }, function() {

        } );
        kxios.interceptors.response.use( function(data) {
            console.log('response - 2', data);
            return data;
        }, function() {

        } );

        // kxios({
        //     url: '/users'
        // }).then(data => {
        //     console.log(data);
        // });

        kxios.get('/users').then(data => {
            console.log(data);
        },()=>{});


        // kxios.request('post', '/user');
    }
</script>
</body>
</html>
